package com.fanfanwang.ffw.app.net;

import java.util.LinkedHashMap;

import org.json.JSONException;

import com.fanfanwang.ffw.app.bean.SucAddParkNum;
import com.fanfanwang.ffw.app.bean.SucDelParkNum;
import com.fanfanwang.ffw.app.bean.SucGetMsgListBean;
import com.fanfanwang.ffw.app.bean.SucParkIsRegBean;
import com.fanfanwang.ffw.app.bean.SucParkNumBean;
import com.fanfanwang.ffw.app.bean.SucSetParknumStatusBean;
import com.fanfanwang.ffw.app.bean.SucSetparkNewPasswordBean;
import com.fanfanwang.ffw.app.bean.SucUserBean;
import com.fanfanwang.ffw.app.net.HttpRequest.HttpRequestException;
import com.fanfanwang.ffw.app.tools.LogUtil;

import android.content.Context;

public class IssNetLib {
	private static IssNetLib mLib;
	private FfwParse mParse;
	XSHttpService xsHttpService;

	private IssNetLib(Context context) {
		xsHttpService = new XSHttpService();
		mParse = new FfwParse();
	}

	public synchronized static IssNetLib getInstance(Context context) {
		if (mLib == null) {
			mLib = new IssNetLib(context);
		}
		return mLib;
	}

	public SucUserBean getLogin(String methodName, LinkedHashMap<String, Object> paramsMap) throws HttpRequestException, JSONException {
		String json = xsHttpService.requestLogin(methodName, paramsMap);
		LogUtil.e("IssNetLib", "getLogin    >>>>" + json);
		return FfwParse.parseUser(json);
	}

	/**
	 * 解析，用户是否已经注册过
	 * @param methodName
	 * @param paramsMap
	 * @return
	 * @throws HttpRequestException
	 * @throws JSONException
	 */
	public SucParkIsRegBean getParkIsReg(String methodName, LinkedHashMap<String, Object> paramsMap) throws HttpRequestException, JSONException {
		String json = xsHttpService.requestParkIsReg(methodName, paramsMap);
		LogUtil.e("IssNetLib", "getLogin    >>>>" + json);
		return FfwParse.parseSucParkIsRegBean(json);
	}
	/**
	 * 解析，设置商户密码
	 * @param methodName
	 * @param paramsMap
	 * @return
	 * @throws HttpRequestException
	 * @throws JSONException
	 */
	public SucSetparkNewPasswordBean setparkNewPassword(String methodName, LinkedHashMap<String, Object> paramsMap) throws HttpRequestException, JSONException {
		String json = xsHttpService.requestSetParkNewPassword(methodName, paramsMap);
		LogUtil.e("IssNetLib", "getLogin    >>>>" + json);
		return FfwParse.parseSucSetParkNewPassword(json);
	}
	/**
	 *i.	getParknumList获取停车位列表
	 * 
	 * @param mobile
	 * @return
	 * @throws HttpRequestException
	 * @throws JSONException
	 */
	public SucParkNumBean getParknumList(String methodName, LinkedHashMap<String, Object> paramsMap) throws HttpRequestException, JSONException {
		String json = xsHttpService.requestParking(methodName, paramsMap);
		LogUtil.e("IssNetLib", "getParknumList    >>>>" + json);
		return FfwParse.parseGetParknumList(json);
	}
	/**
	 *ii.	addParknums添加停车位
	 * 
	 * @param mobile
	 * @return
	 * @throws HttpRequestException
	 * @throws JSONException
	 */
	public SucAddParkNum addParknums(String methodName, LinkedHashMap<String, Object> paramsMap) throws HttpRequestException, JSONException {
		String json = xsHttpService.addParknum(methodName, paramsMap);
		LogUtil.e("IssNetLib", "getParknumList    >>>>" + json);
		return FfwParse.parseAddParknums(json);
	}
	/**
	 *iii.	delParknum删除停车位
	 * 
	 * @param mobile
	 * @return
	 * @throws HttpRequestException
	 * @throws JSONException
	 */
	public SucDelParkNum delParknums(String methodName, LinkedHashMap<String, Object> paramsMap) throws HttpRequestException, JSONException {
		String json = xsHttpService.delParknum(methodName, paramsMap);
		LogUtil.e("IssNetLib", "getParknumList    >>>>" + json);
		return FfwParse.parseDelParknums(json);
	}
	/**
	 *iv.	setParknumStatus更改停车位状态
	 * 
	 * @param mobile
	 * @return
	 * @throws HttpRequestException
	 * @throws JSONException
	 */
	public SucSetParknumStatusBean setParknumStatus(String methodName, LinkedHashMap<String, Object> paramsMap) throws HttpRequestException, JSONException {
		String json = xsHttpService.setParknumStatus(methodName, paramsMap);
		LogUtil.e("IssNetLib", "getParknumList    >>>>" + json);
		return FfwParse.parseSetParknumStatus(json);
	}
	/**
	 *i.	getMsgList获取预约消息
	 * 
	 * @param mobile
	 * @return
	 * @throws HttpRequestException
	 * @throws JSONException
	 */
	public SucGetMsgListBean getMsgList(String methodName, LinkedHashMap<String, Object> paramsMap) throws HttpRequestException, JSONException {
		String json = xsHttpService.getMsgList(methodName, paramsMap);
		LogUtil.e("IssNetLib", "getParknumList    >>>>" + json);
		return FfwParse.parseGetMsgList(json);
	}


}
